package HomeWork;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;

public class Teacher implements Serializable{
    private String name;// 姓名
    private int age;// 年龄
    private double salary;// 工资
    // 无参构造函数
    Teacher(){
        this.name = null;
        this.age = 0;
        this.salary = 0;
    }
    // 有参构造函数
    Teacher(String name,int age,double salary){
        this.name = name;
        this.age = age;
        this.salary = salary;
    }
    public int getAge() {
        return age;
    }
    public String getName() {
        return name;
    }
    public double getSalary() {
        return salary;
    }
    public void setAge(int age) {
        this.age = age;
    }
    public void setName(String name) {
        this.name = name;
    }
    public void setSalary(double salary) {
        this.salary = salary;
    }
    public String toString(){
        String temp = this.name+"-"+
        Integer.toString(this.age)+"-"+
        String.valueOf(this.salary);
        return temp;
    }
    public boolean isNull(){
        if(this.name == null){
            return true;
        }
        else{
            return false;
        }
    }
    // 自定义序列化逻辑
    private void writeObject(ObjectOutputStream out) throws IOException {
        out.defaultWriteObject(); // 默认序列化所有非transient字段
        
    }

    // 自定义反序列化逻辑
    private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
        in.defaultReadObject(); // 默认反序列化所有非transient字段
    }
}
